<template>
  <div id="tag">
    <div class="container">
      <Title>标签管理</Title>
      <el-row>
        <el-col :span="12">
          <div class="search">
            <el-input
              placeholder="请输入内容"
              v-model="keywords"
              suffix-icon="el-icon-search"
            ></el-input>
          </div>
        </el-col>
        <el-col :span="12"
          ><el-button type="primary" style="float: right">
            新增标签
          </el-button></el-col
        >
      </el-row>
      <el-table :data="tableData" border style="width: 100%" stripe>
        <el-table-column
          fixed
          align="center"
          prop="id"
          label="编号"
          width="150"
        >
        </el-table-column>
        <el-table-column align="center" prop="tag" label="标签名称" width="200">
        </el-table-column>
        <el-table-column
          align="center"
          prop="username"
          label="添加人"
          width="150"
        >
        </el-table-column>
        <el-table-column
          align="center"
          prop="last_time"
          label="最后修改时间"
          width="420"
        >
        </el-table-column>
        <el-table-column label="使用状态" align="center" width="200">
          <template slot-scope="scope">
              <el-switch
                v-model="scope.row.status"
                active-color="#13ce66"
                inactive-color="#ff4949"
                active-text="启用"
                inactive-text="禁用"
                active-value="1"
                inactive-value="0"
              >
              </el-switch>
          </template>
        </el-table-column>
        <el-table-column fixed="right" align="center" label="操作" width="200">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text"
              >编辑</el-button
            >
            <el-button type="text" style="color:red">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getTagList } from "@/http/api";
export default {
  name: "TagManage",

  data() {
    return {
      keywords: "",
      skip: 1,
      limit: 10,
      tableData: [],
    };
  },

  mounted() {
    this.getTagList();
  },

  methods: {
    handleClick(row) {
      console.log(row);
    },
    async getTagList() {
      const { data, code } = await getTagList({
        skip: this.skip,
        limit: this.limit,
      });
      if (code == 200) {
        this.tableData = data.list;
      }
    },
  },
};
</script>

<style scoped lang="less">
#tag {
  background-color: rgba(242, 247, 251, 1);
  padding: 20px 30px;
  .container {
    background-color: #fff;
    padding: 0 20px;
  }
}

.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}

.grid-content {
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
}

.search {
  width: 50%;
}
</style>
